#!/usr/bin/env python3

def tri(start=1):
    while True:
        yield int((start*(start+1))/2)
        start += 1
        
def pent(start=1):
    while True:
        yield int((start*((start*3)-1))/2)
        start += 1
        
def hexa(start=1):
    while True:
        yield int(start*((start*2)-1))
        start += 1

START = 144
t = tri(286)
tn = next(t)
p = pent(166)
pn = next(p)

for x in hexa(START):
    while x > tn:
        tn = next(t)
    while x > pn:
        pn = next(p)
    if x == tn == pn:
        print(x)
        break